#include<bits/stdc++.h>
using namespace std;
const int N = 80;
int s,q,f[N][N][N][N][2];
int dfs(int a,int b,int c,int d,int op)
{
	if(a<=0) return 0;
	if(c<=0) return 1;
	int &x = f[a][b][c][d][op];
	if(x!=-1) return x;
	if(op)
	{
		int res = 0;
		if(d>0) res|=dfs(a,b,c,d-1,op^1);
		res|=dfs(a,b,c-max(a-s*d,0),d,op^1);
		return x = res;
	}
	else
	{
		int res = 1;
		if(b>0) res&=dfs(a,b-1,c,d,op^1);
		res&=dfs(a-max(c-s*b,0),b,c,d,op^1);
		return x = res;
	}
}
signed main()
{
	freopen("game.in","r",stdin);
	freopen("game.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	memset(f,-1,sizeof f);
	cin>>s>>q;
	while(q--)
	{
		long long a,b,c,d;
		cin>>a>>b>>c>>d;
		int res = dfs(a,b,c,d,1);
		if(res) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

